//
//  RegisterViewController.m
//  Double
//
//  Created by dllo on 15/5/23.
//  Copyright (c) 2015年 袁庆秋. All rights reserved.
//

#import "RegisterViewController.h"
#import "UserInformationDatabase.h"
#import "UserInformationModel.h"
#import "DB.h"

@interface RegisterViewController ()

@end

@implementation RegisterViewController

- (void)dealloc
{
    [_NameField release];
    [_PassWordField release];
    [super dealloc];
}

- (void)awakeFromNib
{
    [super awakeFromNib];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [self createView];
    
    // Do any additional setup after loading the view.
}
#pragma mark 注册界面
- (void)createView
{
    UIButton * RegisterButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 50, 30)];
    [RegisterButton setTitle:@"注册" forState:UIControlStateNormal];
    [RegisterButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [RegisterButton addTarget:self action:@selector(RegisterAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * RegisterItem = [[UIBarButtonItem alloc]initWithCustomView:RegisterButton];
    self.navigationItem.rightBarButtonItem = RegisterItem;
    
    self.NameField = [[UITextField alloc]initWithFrame:CGRectMake(20, 30, self.view.frame.size.width - 40, 40)];
    [_NameField setPlaceholder:@"请输入用户名"];
    [_NameField setBorderStyle:UITextBorderStyleRoundedRect];
    [self.view addSubview:_NameField];
    
    self.PassWordField = [[UITextField alloc]initWithFrame:CGRectMake(20, 80, self.view.frame.size.width - 40, 40)];
    [self.PassWordField setPlaceholder:@"请输入密码"];
    [self.PassWordField setBorderStyle:UITextBorderStyleRoundedRect];
    [self.view addSubview:self.PassWordField];
    
//    UITextField * VerifyField = [[UITextField alloc]initWithFrame:CGRectMake(20, 130, self.view.frame.size.width - 150, 40)];
//    [VerifyField setPlaceholder:@"请输入验证码"];
//    [VerifyField setBorderStyle:UITextBorderStyleRoundedRect];
//    [self.view addSubview:VerifyField];
//    
//    UIButton * GetVerifyButton = [[UIButton alloc]initWithFrame:CGRectMake(VerifyField.frame.size.width + 30, 130, 100, 40)];
//    [GetVerifyButton setTitle:@"获取验证码" forState:UIControlStateNormal];
//    [GetVerifyButton setBackgroundColor:[UIColor orangeColor]];
//    [self.view addSubview:GetVerifyButton];
}
- (void)RegisterAction:(id)sender
{
    NSString *num = self.NameField.text;
    NSInteger password = [self.PassWordField.text integerValue];
    UserInformationModel * model = [UserInformationModel UserInformationModelWithNum:num PassWord:password];
    [UserInformationDatabase insertWithModel:model];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
